/**********************************************
*  Classes:   CdnResourceLoader
*  Desc:      Manager that loads all resources
*			  that are supported by Coden. Singleton
*			  class
*  Author:    Vaios Kalpias-Ilias (C) 2008-2009
***********************************************/

#ifndef CDNRESOURCELOADER_H
#define CDNRESOURCELOADER_H

#include <map>
#include "SmartPointer.h"

class TextureProperty;
SmartPointer(TextureProperty);
class GeometryNode;
SmartPointer(GeometryNode);

class CdnRenderer;

class CdnResourceLoader
{
public:
	
	// returns single instance
	static CdnResourceLoader* GetInstance();
	// destroys single instance
	static void Destroy();
	// loads a geometry file
	GeometryNodePtr LoadGeometryResource(const char* filename);
	// loads a texture
	TexturePropertyPtr LoadTextureResource(const char* filename,
		bool bUseMipMaps = false);
	
	// resource getters
	TexturePropertyPtr GetTexture (const char* id);
	GeometryNodePtr    GetGeometryNode (const char* id);
	void		       GetMultipleGeometryNodes(const char* id, 
												unsigned int numOfNodes,
												GeometryNodePtr preAllocatedResult[]);

	// unloads resources
	void UnloadResources();

private:

	typedef std::map<const char*, TexturePropertyPtr> TextureMap;
	typedef std::map<const char*, GeometryNodePtr> GeometryMap;

	// single instance
	static CdnResourceLoader* m_pInstance;
	// ptr to renderer
	CdnRenderer* m_pRenderer;
	// map that holds all of our textures
	TextureMap m_Textures;
	// map that holds all of our geometry nodes
	GeometryMap m_Geometry;

	// ctor - dtor
	CdnResourceLoader();
	~CdnResourceLoader();
};

#endif